unit UFrmNiver;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, Wwdbigrd, Wwdbgrid, StdCtrls, Mask, ExtCtrls, ToolEdit, RXCtrls,
  Buttons;

type
  TFrmniver = class(TForm)
    wwDBGrid1: TwwDBGrid;
    RadioGroup1: TRadioGroup;
    DateEdit1: TDateEdit;
    RxLabel1: TRxLabel;
    RxLabel2: TRxLabel;
    Bevel1: TBevel;
    RxLabel3: TRxLabel;
    Bevel2: TBevel;
    BitBtn4: TBitBtn;
    SpeedButton1: TSpeedButton;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure RadioGroup1Click(Sender: TObject);
    procedure DateEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure wwDBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure SpeedButton1Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frmniver: TFrmniver;
  cli : string;

implementation
uses modulo, UFrmclientes, Ufrmrelniver;
{$R *.DFM}

procedure TFrmniver.FormShow(Sender: TObject);
begin
   DMEscola.Qniver.close;
   DMEscola.Qniver.SQL.Clear;
   DMEScola.Qniver.SQL.Add('Select * From Clientes');
   DMEscola.Qniver.open;
end;

procedure TFrmniver.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   Action := CaFree;
end;

procedure TFrmniver.RadioGroup1Click(Sender: TObject);
begin
   if RadioGroup1.ItemIndex = 0 then
   begin
      DMEscola.Qniver.close;
      DMEscola.Qniver.SQL.Clear;
      DMEScola.Qniver.SQL.Add('Select * From Clientes');
      DMEscola.Qniver.open;
      wwDBGrid1.SetFocus
   end;
   if RadioGroup1.ItemIndex = 1 then
   begin
      DMEscola.Qniver.close;
      DMEscola.Qniver.SQL.Clear;
      DMEScola.Qniver.SQL.Add('Select * From Clientes');
      DMEscola.Qniver.SQL.Add('Where extract(month from data_ncto) = :mes');
      DMEscola.Qniver.ParamByName('mes').AsInteger := StrToInt(formatDateTime('mm',Date));
      DMEscola.Qniver.open;
      wwDBGrid1.SetFocus
   end;
   if RadioGroup1.ItemIndex = 2 then
   begin
      DMEscola.Qniver.close;
      DMEscola.Qniver.SQL.Clear;
      DMEScola.Qniver.SQL.Add('Select * From Clientes');
      DMEscola.Qniver.SQL.Add('where extract(month from data_ncto) = :mes and');
      DMEscola.Qniver.SQL.Add('extract(day from data_ncto) = :dia');
      DMEscola.Qniver.ParamByName('mes').AsInteger := StrToInt(formatDateTime('mm',Date));
      DMEscola.Qniver.ParamByName('dia').AsInteger := StrToInt(formatDateTime('dd',Date));
      DMEscola.Qniver.open;
      wwDBGrid1.SetFocus
   end;
   if RadioGroup1.ItemIndex = 3 then
   begin
      DateEdit1.SetFocus;
   end;

end;

procedure TFrmniver.DateEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if Key = VK_Return then
   begin
      DMEscola.Qniver.close;
      DMEscola.Qniver.SQL.Clear;
      DMEScola.Qniver.SQL.Add('Select * From Clientes');
      DMEscola.Qniver.SQL.Add('where extract(month from data_ncto) = :mes and');
      DMEscola.Qniver.SQL.Add('extract(day from data_ncto) = :dia');
      DMEscola.Qniver.ParamByName('mes').AsInteger := StrToInt(formatDateTime('mm',DateEdit1.Date));
      DMEscola.Qniver.ParamByName('dia').AsInteger := StrToInt(formatDateTime('dd',DateEdit1.Date));
      DMEscola.Qniver.open;
      wwDBGrid1.SetFocus
   end;
end;

procedure TFrmniver.wwDBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key = VK_return then
   begin
      cli := DMEscola.QniverNome.Value;
      FrmClientes := TFrmClientes.Create(self);
      close;
      FrmClientes.showmodal
   end;
end;

procedure TFrmniver.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key = VK_F12 then
      bitbtn4.Click;
end;

procedure TFrmniver.SpeedButton1Click(Sender: TObject);
begin
   frmrelniver := tfrmrelniver.create(self);
   frmrelniver.QuickRep1.Preview;
end;

procedure TFrmniver.BitBtn4Click(Sender: TObject);
begin
   close
end;

end.
